<?php
/*
 * generate.php
 * Retral/CSCD494 Winter 2009
 * Eastern Washington University
 *
 * File Description:
 * Allow a user to generate an exam.
 * Uses a dropdown calendar to choose date (see scriptaculous/scw.js for credits)
 * 
 * Other:
 * 
 */

/* 
 * Set up $page_name
 * This name will be compared to PAGE_NAME in NAV_URLS table (stored in session) and verify permission for given user.
 */
$page_name = "Generate";
$page_name = strtoupper($page_name);

$pm = $_SESSION['pagePermissions'];
$_SESSION['generateCycle'] = 1;
$_SESSION['selectQID'] = 0;
$_SESSION['selectQV'] = 0;
//
//Print_r($_SESSION);
// Is user logged in, and has permissions?
if (isset($_SESSION['loggedIn']) && $_SESSION['loggedIn'] !="" && $_SESSION['pagePermissions'][$page_name] == 1)
{
?>
		<!-- include calendar javascript -->
		<script type="text/javascript" src="scriptaculous/scw.js"></script>
		<span class="header-text">CREATE A NEW EXAM</span><br>

		<h2>NEW EXAM</h2>
		<form action="http://cscd494-l.cslabs.ewu.edu:8080/apegen" method="POST">
			<ul>
				<li>Select a date for your exam:
					<input type="text" name="examdate" cols="11" onclick='scwShow(this,event);' value=''>
						MM/DD/YYYY
	
				<input type="hidden" name="runCode" id ="runCode" value="generate" />
			</ul>
					<!-- TODO: This should come from current user-->

					<input type="hidden" value="<?php echo $_SESSION['userID']; ?>" name="authorID"> 
					<input type="submit" class="button" value="NEXT"/>
		</form>
<?php
}
else
{
	echo "Invalid credentials";
	echo "<META http-equiv=\"refresh\" content=\"0;URL=index.php?page=login&ld=0\">";
}	
?>
